package org.example.stu;


import java.time.*;
import java.time.format.DateTimeFormatter;



public class RunoobTest {


/*
//*  Java StringBuffer 和 StringBuilder 类 *
    public static void main(String[] args){
        StringBuilder sb = new StringBuilder(10);
        sb.append("Runoob..");
        System.out.println(sb);
        sb.append("!");
        System.out.println(sb);
        sb.insert(8, "Java");
        System.out.println(sb);
        sb.delete(5,8);
        System.out.println(sb);


        // 字符改写
        StringBuffer sBuffer = new StringBuffer("菜鸟教程官网：");
        sBuffer.append("www");
        sBuffer.append(".runoob");
        sBuffer.append(".com");
        System.out.println(sBuffer);
*/


    public static void main(String[] args) {
        // 获取当前日期
        LocalDate today = LocalDate.now();
        System.out.println("当前日期: " + today);

        // 创建特定日期
        LocalDate nationalDay = LocalDate.of(2025, 10, 1);
        System.out.println("国庆节: " + nationalDay);

        // 日期加减
        LocalDate tomorrow = today.plusDays(1);
        LocalDate nextMonth = today.plusMonths(1);
        LocalDate lastYear = today.minusYears(1);

        System.out.println("明天: " + tomorrow);
        System.out.println("下个月: " + nextMonth);
        System.out.println("去年今天: " + lastYear);


        System.out.println("======================================<LocalDate (日期)>=============================================");

        LocalTime now = LocalTime.now();
        LocalTime time = LocalTime.of(14, 30, 45);  // 14:30:45
        int hour = time.getHour();  // 14
        int minute = time.getMinute();  // 30
        LocalTime nextHour = time.plusHours(1);
        System.out.println("hour: " + hour);
        System.out.println("minute: " + minute);
        System.out.println("nextHour: " + nextHour);

        System.out.println("======================================<ZonedDateTime (带时区日期时间)>=============================================");
        ZonedDateTime zdt = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
        ZonedDateTime nyTime = zdt.withZoneSameInstant(ZoneId.of("America/New_York"));
        ZoneId zone = zdt.getZone();  // 获取时区
        System.out.println(zone);

        /*时间格式的处理后期可以参考 菜鸟教程的知识点
        *
        * 1、框架学习 大致的了解逻辑
        * 2、知识积累 知道编写的逻辑
        * */



    }
}
